define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	
	var Model = function(){
		this.callParent();
	};
	
	Model.prototype.toUrl = function(url){
		return url ? require.toUrl(url) : "";
	};
	
	
	Model.prototype.regBtnClick = function(event){
		var phoneInput=this.comp("phoneInput").val();
		var UserData=this.comp("UserData");
		var registerData=this.comp("registerData");
		var passwordInput=this.comp("passwordInput").val();
		var rePasswordInput=this.comp("rePasswordInput").val();
		var mailInput=this.comp("mailInput").val();
		var reg = /^0?1[3|4|5|7|8][0-9]\d{8}$/;
		var passwordReg=/^[a-zA-Z0-9]{6,20}$/;
		if(reg.test(phoneInput)){
			UserData.clear();
			UserData.setFilter("fPhoneFilter","fPhone ='"+ phoneInput +"'");
			UserData.refreshData();
			if(UserData.count() > 0){
				justep.Util.hint("该号码已注册过，请重新输入手机号！");
			}else{
				if(!passwordInput){
					justep.Util.hint("请输入密码！");
				}else{
					if(passwordReg.test(passwordInput)){
						if(passwordInput == rePasswordInput){
							registerData.newData({
								"defaultValues" : [ {
									"fPhone": phoneInput,
									"fPassword":passwordInput,
									"fMail" : mailInput
								} ]
							});
							registerData.saveData();
						}else
							justep.Util.hint("两次密码输入不一致！");
					}else
						justep.Util.hint("密码格式输入不正确！");	
				}
			}
		}else
			justep.Util.hint("手机号码不正确！");	
	};
	
	
	Model.prototype.registerDataAfterSave = function(event){
		justep.Shell.showPage("Login");
		justep.Util.hint("恭喜您！注册成功！");
	};
	
	
	
	
	
	return Model;
});